package com.jiandian.service;

import com.jiandian.entity.SignLog;
import com.jiandian.entity.SignUser;
import com.jiandian.page.PageInfo;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;

/**
 * 签到记录
 *
 * @author houqi Fu
 * @date 2018/12/15
 */
public interface SignLogService {

    SignLog add(SignLog record);

    SignLog update(SignLog record);

    SignLog findById(Long id);

    List<SignLog> findAll(PageInfo pageInfo);

    int selectCount(PageInfo pageInfo);

    int batchInsert(List<SignLog> list);

    List<SignLog> batchQueryByIds(List<Long> ids);

    int delete(Long id);

    int delete(SignLog record);

    int batchDeleteById(List<Long> ids);

    PageInfo getPage(SignLog whereEntity, PageInfo pageInfo);

    /**
     * 计算连续签到天数（根据数据库记录）
     * @param userId
     * @return
     */
    int clacContinueSignDays(int userId);

    /**
     * 增加补签记录
     * @param userId
     * @param time
     */
    void addSuppleSignLog(int userId, LocalDate time);

    List<SignLog> selectByUserId(int userId);

    SignUser consumeSupplement(SignUser signUser, int intervalDayCount, int supplementCount, LocalDate lastDate);

    /**
     * 获取最后签到的一条记录
     * @param userId
     * @return
     */
    SignLog getLastSignDay( int userId);

}
